package org.veridiandynamics.server.test;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.veridiandynamics.server.domain.Admin;
import org.veridiandynamics.server.domain.Appointment;
import org.veridiandynamics.server.domain.Doctor;
import org.veridiandynamics.server.domain.DoctorsOrders;
import org.veridiandynamics.server.domain.Invoice;
import org.veridiandynamics.server.domain.Nurse;
import org.veridiandynamics.server.domain.Patient;
import org.veridiandynamics.server.domain.Schedule;
import org.veridiandynamics.server.domain.TreatmentRecord;
import org.veridiandynamics.server.model.PatientModel;

public class DomainDriver {
	
	public static void main(String[] args) throws ParseException 
	{
		//initializing values to be used later
		Map<String, String> patientInfo = new HashMap<String, String>();
		patientInfo.put("Name", "Lee");
		DateFormat df = new SimpleDateFormat("dd/MM/yyyy-HH:mm:ss");
		Date startDate = df.parse("06/09/2011-14:23:22");
		Date endDate = df.parse("06/09/2011-14:53:22");
		Date conflStartDate = df.parse("06/09/2011-14:33:22");
		Date conflEndDate = df.parse("06/09/2011-14:50:00");
		Doctor patientDoctor = new Doctor(patientInfo, true);
		Patient patient = new Patient(patientInfo, patientDoctor);
		
		//make admin and checking values
		System.out.println("Making a new Admin: ");
		Admin admin = new Admin(patientInfo);
		System.out.println("Success! New Admin created! toString is " + admin.toString());
		
		//making appointments

		System.out.println("Making an appointment: ");
		Appointment appointment = new Appointment(startDate, endDate, patientDoctor,
				patient, "I'm dying");
		System.out.println("Success! New Appointment created! toString is " + appointment.toString());
		
		//making a Doctor
		System.out.println("Making a new Doctor: ");
		Doctor sampleDoctor = new Doctor(patientInfo, true);
		System.out.println("Success! New Doctor created! toString is " + sampleDoctor.toString());
		
		//printing out an invoice
		Map<String, Float> itemizedList = new HashMap<String, Float>();
		itemizedList.put("Took blood pressure", 50f);
		itemizedList.put("Checked blood glucose levels", 50f);
		System.out.println("Making a new invoice: ");
		Invoice invoice = new Invoice(appointment, itemizedList);
		System.out.println("Success! Invoice created, toString is " + invoice.toString());
		
		//printing out a nurse
		System.out.println("Making a new Nurse: ");
		Nurse treatmentNurse = new Nurse(patientInfo, false);
		System.out.println("Success! Nurse created, toString is " + treatmentNurse.toString());
		
		//printing out a Patient
		System.out.println("Making a new Patient: ");
		Patient samplePatient = new Patient(patientInfo, sampleDoctor);
		System.out.println("Success! Patient created, toString is " + samplePatient.toString());
		
		//making a schedule
		System.out.println("Making a new Schedule: ");
		Schedule schedule = new Schedule(patientDoctor);
		System.out.println("Success! Schedule created, toString is " + schedule.toString());
		System.out.println("Adding appointment to schedule: ");
		List<Appointment> testList = new ArrayList<Appointment>();
		testList.add(appointment);
		schedule.setSchedule(testList);
		System.out.println("Success! Appointment added, toString is now " + schedule.toString());
		
		//treatmentRecord
		List<TreatmentRecord> recordList = new ArrayList<TreatmentRecord>();
		ArrayList<String> labWork = new ArrayList<String>();
		labWork.add("Blood test");
		labWork.add("Killer bees");
		DoctorsOrders orders = new DoctorsOrders("None", "Windex", labWork, "Patient Dead");
		Map<String, String> vitalSigns = new HashMap<String, String>();
		vitalSigns.put("Weight", "Over 9000");
		vitalSigns.put("Height", "Longcat");
		for (int i = 0; i < 2; i++) {
			TreatmentRecord record = new TreatmentRecord(treatmentNurse,
														 orders,
														 "Axe in chest",
														 vitalSigns,
														 "AXE IN CHEST",
														 patient,
														 startDate);
			recordList.add(record);											 
					
		}
		patient.setTreatmentRecordList(recordList);
		int i = 0;
		for (TreatmentRecord record : patient.getTreatmentRecordList()) {
			System.out.println("TreatmentRecord: " + Integer.toString(i+1));
			System.out.println(record.toString());
			System.out.println("-------------------------------------------");
			i++;
		}
		
		//doing an appointment conflict
//		System.out.println("Making a conflicting appoitnment:");
//		Appointment conflAppointment = new Appointment(conflStartDate, conflEndDate,
//				patientDoctor, patient, "I'm dying");
//		PatientModel conflictTest = new PatientModel();
//		conflictTest.makeAppointment(appointment);
//		conflictTest.makeAppointment(conflAppointment);
		

		
		
		
		
	}

}
